<template>
	<div>
		<div class="tabNav">
			<router-link to="/index">
        <img src="../assets/img/sidebar1.png" />首页
      </router-link>
      <b>/<img style="top: 1px" src="../assets/img/assignment.png" />任务信息</b>
			<el-input 
				placeholder="请输入企业名称/任务名称/灵活用工平台名称进行搜索" 
				suffix-icon="el-icon-search" 
				@change="searchMethods"
				v-model="searchValue">
			</el-input>
			<em><i style="font-size: 16px;margin-right: 5px;" class="el-icon-s-data"></i>任务总数量：{{ selectSeviceCountNumber }}</em>
		</div>
		<el-row :gutter="24">
			<el-col :span="24">
				<el-card class="cardTits cardTitss cardTitdd" shadow="hover">
					<v-tasktable ref="searchMethods" :search="searchValue"></v-tasktable>
				</el-card>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	import vTasktable from '../components/table/Tasktable.vue'
	export default {
		name: "dashboard",
		components: {
			vTasktable
		},
		data() {
			return {
				name: localStorage.getItem("ms_username"),
				searchValue: '',
				selectSeviceCountNumber: 0
			};
		},
		computed: {
			role() {
				return this.name === "admin" ? "超级管理员" : "普通用户";
			}
		},
		mounted() {
			this.selectSeviceCount()
		},
		methods: {
			searchMethods() {
				// 搜索
				this.$refs.searchMethods.getTableData()
			},
			selectSeviceCount() {
				// 获取任务数量
				this.$http({
					url: '/api/task/selectTaskCount',
					method: 'post',
					headers: {
						'Content-Type': 'application/json'
					}
				}).then(data => {
					console.log(data)
					if(data.code === 0) {
						this.selectSeviceCountNumber = data.result
					}
				})
			}
		}
	};
</script>
